<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>组合继承</title>
</head>
<body>
<script>
    function Humans(name){
        this.name=name;
        this.clothing=["trousers","dress","jacket"];
    }
    Humans.prototype.sayName=function(){
        alert(this.name);
    };
    function Man(name,age){
        Humans.call(this,name);    //继承属性
        this.age=age;
    }
    Man.prototype=new Humans();    //继承方法
    Man.prototype.sayAge=function(){
        alert(this.age);
    };

    var man1=new Man("mary",38);
    man1.clothing.push("coat");
    alert(man1.clothing);     //输出"trousers,dress,jacket,coat"
    man1.sayName();            //输出mary
    man1.sayAge();            //输出38
    var man2=new Man("tom",26);
    alert(man2.clothing);    //输出"trousers,dress,jacket"
    man2.sayName();            //输出tom
    man2.sayAge();            //输出26
</script>
</body>
</html>